package view;

import java.awt.BorderLayout;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JPanel;
import model.Snake;

public class InfoPanel extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Font fon = new Font("楷体", Font.BOLD, 24);
	Font font = new Font("隶书", Font.PLAIN, 24);
	public static JLabel label[]=new JLabel[3];
	private Snake snake;
	
	public InfoPanel() {
     
	setSize(200, GamePanel.HEIGHT);
	setLayout(null);
	
	
	
	
	String str[]={"状态:","分数:","速度:"};
    for(int i=0;i<str.length;i++){
    JLabel la=new JLabel(str[i]);
    la.setLayout(new BorderLayout());
    la.setBounds(20, 200+i*50, 80, 20);
    la.setFont(fon);
    add(la);
    
    label[i]=new JLabel("null");
    label[i].setBounds(90, 200+i*50, 120, 20);
    add(label[i]);
    label[i].setFont(font);
 
}
}
	public InfoPanel(Snake snake){
		this();
		this.snake=snake;
		
	}
	public void showState(){
		int state =snake.getState();
		switch (state) {
		case Snake.NOSTART:
	    label[0].setText("未开始");
			break;
		case Snake.RUNNING:
		label[0].setText("游戏中");
			break;
		case Snake.PASE:
		label[0].setText("暂停");
			break;
		case Snake.OVER:
		label[0].setText("游戏结束");
			break;
		}

		}
		
	}
